'''
添加全面异常检测
'''
from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup

def getTitle(url):
    try:
        html = urlopen(url)
    except HTTPError as e:
        return None
    try:
        bsObj = BeautifulSoup(html.read(), "html.parser")
        title = bsObj.title
    except AttributeError as e:
        return None
    return title

title = getTitle("https://luxuewen.com/lauwen/index.html")
if title == None:
    print("Title is not found")
else:
    print(title)


